<template>
    <div @click.stop>
        <div class="acc_itemt" @click="openList">{{show_data}}</div>
        <div v-for="(key,index) in tlist" class="acc_item" v-if="open_set" @click="seletItem(key,index)">{{key.name}}</div>
    </div>
</template>
<script>
    import * as vx from 'vuex'
    export default{
        data(){
            return{
                show_data:"",
                tlist:[],
                open_set:false
            }
        },
        props:["list"],
        methods:{
            openList:function () {
                this.open_set=!this.open_set;
            },
            seletItem:function (val,index) {
                this.tlist[index].se=true;
                let arr=[];
                let das="";
                for(let i=0;i<this.tlist.length;i++){
                    if(val.se){
                        this.show_data=val.name
                    }
                    arr.push({
                        name:this.tlist[i].name,
                        se:(i==index?"true":"false")
                    });
                    if(i==index){
                        das=this.tlist[i].name;
                    }
                }
                this.tlist=arr;
                this.open_set=false;
                this.$emit("timeList_d",das)
            }
        },
        watch:{
            c_updated:function () {
                this.open_set=false;
            }
        },
        mounted:function () {
            this.list.forEach((val)=>{
                if(val.se){
                    this.show_data=val.name
                }
                this.tlist.push({
                    name:val.name,
                    se:val.se
                })
            });
        },
        computed:{
            ...vx.mapGetters([
                'c_updated'
            ]),
        }
    }
</script>
<style scoped>

</style>